package executables;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;

import org.json.*;

import util.SequenceComparator;

import data_structs.*;
import errors.DuplicateKey;
import errors.IncorrectNucleotide;

public class RandomCodeTester {

	/**
	 * @param args
	 * @throws JSONException 
	 */
	public static void main(String[] args) throws JSONException {
		
		try {
			SequenceWrapper n1 = new SequenceWrapper("155533", "aggactgcct", 56, false);
			SequenceWrapper n2 = new SequenceWrapper("2351241", "acctg", 3, false);
			
			System.out.println("n1 sequence: "+n1.getSequence());
			System.out.println("n1 intsequence: "+n1.getIntSequence());
			System.out.println("n1 id: "+n1.getID());
			System.out.println("n2 sequence: "+n2.getSequence());
			System.out.println("n2 intsequence: "+n2.getIntSequence());
			System.out.println("n2 id: "+n2.getID());
			
			int compare = n1.compareTo(n2);
			System.out.println("Compare results: "+compare);
			
			SequenceWrapper n3 = new SequenceWrapper("354321", "acctaaccggaggtttc", 4, false);
			System.out.println("n3 sequence: "+n3.getSequence());
			System.out.println("n3 intsequence: "+n3.getIntSequence());
			System.out.println("n3 id: "+n3.getID());
			
			SequenceWrapper n4 = new SequenceWrapper("6542324", "aggactgcct", 55, false);
			
			TreeMap<SequenceWrapper, SequenceWrapper> tm = new TreeMap<SequenceWrapper, SequenceWrapper>(new SequenceComparator());
			tm.put(n1, n1);
			tm.put(n2, n2);
			tm.put(n3, n3);
			if( tm.put(n4, n4) == null ){
			
			Set set = tm.entrySet();
			for( Object sw : set )
				System.out.println(sw);
			}
			
			HashRB<SequenceWrapper> hrb = new HashRB<SequenceWrapper>();
			hrb.add(n1); hrb.add(n2); hrb.add(n3);
			
			boolean b = true;
			System.out.println(b);
			
//			JSONObject j = new JSONObject("{seq:\"aattccgtgtga\",id:65465463,position:45,matches:[" +
//					"{seq:\"aattccgtgtga\",id:45642348,position:36}," +
//					"{seq:\"aattccgtgtga\",id:64657,position:4}]}");
			JSONObject j = new JSONObject();
			j.put("seq", "aattccgtgtga");
			j.put("id", 65465463);
			j.put("position", 45);
			j.put("matches",new JSONArray());
			System.out.println(j.put("seq", "tttttttt"));
			System.out.println("j: "+j);
			System.out.println(j.length());
//			System.out.println(j.accumulate("matches", "{seq:\"aattccgtgtga\",id:3465,position:78}"));
//			System.out.println(j.accumulate("matches", "{seq:aattccgtgtga,id:65656545,position:1"));
			System.out.println("j: "+j);
			System.out.println(j.getJSONArray("matches"));
			
			
		} catch (IncorrectNucleotide e) {
			System.err.println("WHOOPS!");
			e.printStackTrace();
		} catch (DuplicateKey e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
